package es.wtestgen.bean.inicio;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;


public class LoginForm extends ActionForm {
	
	private static final long serialVersionUID = -7490206021027738760L;
	private String nombreUsua = null;
	private String pwdUsua = null;
	
	public LoginForm(){
	}

	public String getNombreUsua() {
		return nombreUsua;
	}


	public void setNombreUsua(String nombreUsua) {
		this.nombreUsua = nombreUsua;
	}


	public String getPwdUsua() {
		return pwdUsua;
	}


	public void setPwdUsua(String pwdUsua) {
		this.pwdUsua = pwdUsua;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
		
		ActionErrors errors = new ActionErrors();
		
		/*
		 * Validamos que el usuario y la password no sean nulos
		 */
		if(getNombreUsua() == null || getNombreUsua().equals("")){
			errors.add("nombreUsua",new ActionMessage("error.usuarioNulo"));
		}
		if(getPwdUsua() == null || getPwdUsua().equals("")){
			errors.add("pwdUsua",new ActionMessage("error.passwordNulo"));
		}
		
		return errors;		
	}

}
